﻿import mx.utils.Delegate;

import com.gamemeal.physics.Point3;
import com.gamemeal.renderer.Cam3D;
import com.gamemeal.renderer.MCTransform;
/**
 * @author Colin
 */

/**
 * @author Colin
 */
class com.gamemeal.renderer.Flat3D{
	private var cm:Cam3D;
	private var pos:Point3;
	private var trns:MCTransform;
	private var mc:MovieClip;

	public function Flat3D(mc:MovieClip,x:Number,y:Number,z:Number){
		this.mc = mc;
		cm = Cam3D.instance();
		pos = new Point3(x,y,z);
		mc.onEnterFrame = Delegate.create(this,onEnterFrame); 
	}
	
	private function onEnterFrame(){
		if(cm.isEnable == true){
			trns = cm.project3Dto2DMCTransform(pos);
			mc._x = trns.x;
			mc._y = trns.y;
			mc._xscale = trns.xs;
			mc._yscale = trns.ys;
			mc.swapDepths(trns.depth);
		}
	}
}